<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" encoding="gb2312"></xsl:output>
<xsl:template match="/roster">
	<html>
		<head>
			<title>实验六</title>
		</head>
		<body>
		<xsl:variable name="sum_score" select="sum(student/score)"/>
		<xsl:variable name="count_person" select="count(student)"/>
		<xsl:variable name="average_score" select='format-number($sum_score div $count_person,"#.0")'/>
		<xsl:variable name="score_60" select="count(student[score&lt;60]/score)"/>
		<xsl:variable name="score_85" select="count(student[(score&gt;85 or score = 85) and sex='女']/score)"/>
			<table border="1" align="center">
				<tr><xsl:attribute name="bgcolor">lightgray</xsl:attribute>
					<th>编号</th>
					<th>姓名</th>
					<th>性别</th>
					<th>生日</th>
					<th>成绩</th>
					<th>评价</th>
				</tr>
				<xsl:for-each select="student">
				<xsl:sort select="score" order="descending" data-type="number"/>
					<tr>
					<xsl:if test="@ID mod 2=0">
						<xsl:attribute name="bgcolor">green</xsl:attribute>
					</xsl:if>
					<td><xsl:value-of select="@ID"/></td>
					<td>
					<font>
						<xsl:if test="sex='女'">
							<xsl:attribute name="color">blue</xsl:attribute>
						</xsl:if>
						<xsl:value-of select="name"/>
					</font></td>
					<td><xsl:value-of select="sex"/></td>
					<td><xsl:value-of select="birthday"/></td>
					<td><xsl:value-of select="score"/></td>
					<xsl:choose>
							<xsl:when test="score &gt; 90">
							<td><font>优秀</font></td>
							</xsl:when>
							<xsl:when test="score &gt; 80">
							<td><font>良好</font></td>
							</xsl:when>
							<xsl:when test="score &gt;60">
							<td><font>一般</font></td>
							</xsl:when>
							<xsl:otherwise>
							<td><font>不及格</font></td>
							</xsl:otherwise>
						</xsl:choose>
					</tr>
				</xsl:for-each>
					<tr><td colspan='5' align="center">总分</td>
					<td><xsl:value-of select="$sum_score"/>
					</td></tr>
					<tr><td colspan='5' align="center">总人数</td>
					<td><xsl:value-of select="$count_person"/></td></tr>
					<tr><td colspan='5' align="center">平均分</td>
					<td><xsl:value-of select="$average_score"/></td></tr>
			</table>
			<hr width="400"/>
			<div style="text-align:center">
			<font>60分以下的共
			<xsl:value-of select="$score_60"/>
			人</font><br/>
			<font>85分(包含)以上女生共
			<xsl:value-of select="$score_85"/>
			人</font>
			</div>
		</body>
	</html>
</xsl:template>
</xsl:stylesheet>